//
//  Me_ServeCell.swift
//  AirTravel
//
//  Created by tulip on 2021/9/5.
//

import UIKit

class Me_ServeCell: UITableViewCell,UICollectionViewDelegate,UICollectionViewDataSource {
   
    var nameArr:Array<String>=[]
    var imgArr:Array<String>=[]
    @IBOutlet weak var collect: UICollectionView!
    @IBOutlet weak var box: UIView!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        
        box.backgroundColor=UIColor.white
        box.layer.cornerRadius=5
        box.layer.masksToBounds=true
        
        let layout=UICollectionViewFlowLayout.init()
        layout.itemSize=CGSize(width: (SCREEN_WIDTH-145)/4.0, height: 60)
        layout.scrollDirection = .vertical
        layout.sectionInset=UIEdgeInsets(top: 15, left:15, bottom: 15, right: 15)
        layout.minimumLineSpacing=18
        
        collect.collectionViewLayout=layout
        collect.delegate=self
        collect.dataSource=self
        collect.isPagingEnabled=true
        collect.register(UINib(nibName: "OrderBtnColletcell", bundle: nil), forCellWithReuseIdentifier: "serveBtncell")
        imgArr=["会员中心","常用信息","我的钱包","我的积分","我的收藏","购物车","我的地址","意见反馈","联系我们"]
        nameArr=["会员中心","常用信息","我的钱包","我的积分","我的收藏","购物车","我的地址","意见反馈","联系我们"]
        
        
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
        self.selectionStyle = .none
    }
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        imgArr.count
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell:OrderBtnColletcell=collectionView.dequeueReusableCell(withReuseIdentifier: "serveBtncell", for: indexPath) as! OrderBtnColletcell
        cell.lab.text=nameArr[indexPath.row]
        cell.img.image=UIImage(named: imgArr[indexPath.row])
        cell.tag=indexPath.row
        return cell
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let cell:OrderBtnColletcell=collectionView.cellForItem(at: indexPath) as! OrderBtnColletcell
        if cell.tag == 0 {
    
            let vc=WebLoadingViewController()
            vc.filePath = "http://swoole.whichzhen.com/api/user/app_h5?token=\(UserManager.shared.currentUser?.token ?? "")&uid=\(UserManager.shared.currentUser?.id ?? "")&type=2"
            vc.hidesBottomBarWhenPushed=true
            getCurrentVc().navigationController?.pushViewController(vc, animated: true)
        }
        if cell.tag == 1 {
            let vc=RVInfoManageController.init()
            vc.hidesBottomBarWhenPushed=true
            getCurrentVc().navigationController?.pushViewController(vc, animated: true)
        }
        if cell.tag == 2 {
            let vc=RVPurseController.init()
            vc.hidesBottomBarWhenPushed=true
            getCurrentVc().navigationController?.pushViewController(vc, animated: true)
        }
        if cell.tag == 3 {
            let vc=RVIntegralController.init()
            vc.hidesBottomBarWhenPushed=true
            getCurrentVc().navigationController?.pushViewController(vc, animated: true)
        }
        if cell.tag == 4 {
            let vc = RVFavoriteController()
            vc.hidesBottomBarWhenPushed=true
            getCurrentVc().navigationController?.pushViewController(vc, animated: true)
        }
        if cell.tag == 5 {
            let vc=RVShopCartController.init()
            vc.hidesBottomBarWhenPushed=true
            getCurrentVc().navigationController?.pushViewController(vc, animated: true)
        }
        if cell.tag == 6 {
            let vc=RVMyAddressController()
            vc.hidesBottomBarWhenPushed=true
            getCurrentVc().navigationController?.pushViewController(vc, animated: true)
        }
        if cell.tag == 7 {
            let vc=RVFeedbackController.init()
            vc.hidesBottomBarWhenPushed=true
            getCurrentVc().navigationController?.pushViewController(vc, animated: true)
        }
        if cell.tag == 8 {
            
            if let vc = getCurrentVc() as? MeVC {
                vc.clickCantactBtn()
            }
        }
    }
    
    
    
}
